function ticker2(tick,total,frequency)
% ticker2 will estimate the total time necessary to complete processing and it'll output the progress information
%
% For example:
% ticker2();
% for i=1:10000
%   pause(0.01)
%   ticker2(i,10000,10);
% end
%
% One will see something like this
%610 10000 7.60 (1.95 minutes left)
%620 10000 7.72 (1.95 minutes left)
%630 10000 7.85 (1.94 minutes left)
%640 10000 7.97 (1.94 minutes left)
%650 10000 8.10 (1.94 minutes left)
%660 10000 8.22 (1.94 minutes left)
%670 10000 8.35 (1.94 minutes left)
%
%LICENSE: BSD
%Author: Alexander Sorokin,syrnick@gmail.com


global ticker2_begin

if nargin<1
    ticker2_begin=now();
    fprintf('\n');
    return
end
if nargin<3
    frequency=10;
end

if mod(tick,frequency)==0
  timeSpent=(now-ticker2_begin)*100000;
  productivity=(timeSpent/(tick+(tick==0)));
  left=(total-tick)*productivity;
  fprintf('%d %d %0.2f (%0.2f minutes left)\n',[tick total timeSpent left/60]);

end
